<?php

/**
 * 分数线变化分析
 * 
 * @version 1.0
 * @date 2013-12-16
 * @author jinyue.wang
 */

class DefaultController extends FController {

    public $user_school_list;
    public $user_subject_list;
    public $user_role_list;
    public $exam_id;
    public function accessRules() {
        $config = array(
            'index' => 1
        );
        return ZRole::auth("change_scores", $config);
    }

    public function __common() {
        parent::init();
        if (empty($this->cLoginUser)) {
            $this->redirect($this->createUrl('/site/login'));
        } else {
            $userLoginUser = $this->cLoginUser;
            $this->user_role_list = isset($userLoginUser['cuser']['role_id']) ? $userLoginUser['cuser']['role_id'] : '';
            $this->user_school_list = isset($userLoginUser['cuser']['school']['school_id']) ? $userLoginUser['cuser']['school']['school_id'] : '';
            $this->user_subject_list = isset($userLoginUser['cuser']['school']['subject_id']) ? $userLoginUser['cuser']['school']['subject_id'] : '';
            $zRow = new ZRole();
            //得到学校对应的考试
            $exam_list = $zRow->_getSchoolExam($this->user_school_list);
            if (!empty($exam_list)) {
                $this->exam_id = implode(',', $exam_list);
            }
        }

        $this->commonScript();
        Yii::app()->clientScript->registerCssFile(THEME_CSS_URL . '/module_Sip.css');
    }

    public function actionIndex() {
        
        $this->__common();
        
        $zExam = new zExam();
        $examArray = $zExam->_getExamObject($this->exam_id,$this->user_role_list);  //得到考试列表

        $zEdu = new ZEdu();
        if ($this->user_role_list != 1) {
        	$schoolObject = $zEdu->_getSchoolInfo($this->user_school_list);
        }else{
        $schoolObject = $zEdu->_getSchoolInfo();
        }

        $memberShip = $zExam->_getMemberShipObject();
        
        $chagePoint = $zExam->_getPointDiffArray();
        
        $this->title = '分数线变化分析';
        $this->render('index', array(
            'examArray' => $examArray,
            'schoolObject' => $schoolObject,
            'memberShip'    => $memberShip,
            'chagePoint'    => $chagePoint
        ));
    }

    /**
     * 添加分数段
     * 
     * @version 1.0
     * @author jinyue.wang
     * @date 2013-12-16
     */
    public function actionAdd(){
        
        $this->__common();
        $this->layout = "//layouts/main_window";
        
        $zExam = new zExam();
        if(isset($_POST) && !empty($_POST)){
            
            $data = $_POST;
            
            $sql = 'INSERT INTO "{{points_difference}}" ("membership_name") VALUES (:point)';
            $result = Yii::app()->db->createCommand($sql);
            $result->bindParam(':point',$data['point'],PDO::PARAM_STR);
            $status = $result->execute();
            
            $this->redirect('/change_scores/default/index');
            exit;
        }
        
        $this->render('add',array()); 
    }
    
    public function actionUpdate(){
        
        $this->__common();
        $this->layout = "//layouts/main_window";
        
        $pid = $this->request->getParam('pid');
        
        $zExam = new zExam();
        
        $model = array();
        if($pid>0){
            $model = $zExam->_getPointDiff($pid); 
        }
        
        if(isset($_POST) && !empty($_POST)){
            
            $data = $_POST;

            $sql = 'UPDATE "{{points_difference}}" SET "membership_name" = :point WHERE "pd_id" = :pd_id ';
            $result = Yii::app()->db->createCommand($sql);
            $result->bindParam(':point',$data['point'],PDO::PARAM_STR);
            $result->bindParam(':pd_id',$data['pid'],PDO::PARAM_STR);
            $status = $result->execute();
            
            $this->redirect('/change_scores/default/index');
            exit;
        }
        
        $examArray = $zExam->_getExamObject();
        
        $this->render('update',array(
            'model'  => $model,
            'pid'    => $pid
        )); 
        
    }
    
    public function actionDelete(){
        
        $this->__common();
        
        $status = 0;
        
        $pid = $this->request->getParam('pid');
        if($pid>0){
            $sql = 'DELETE FROM "{{points_difference}}" WHERE "pd_id" = :pd_id ';
            $result = Yii::app()->db->createCommand($sql);
            $result->bindParam(':pd_id',$pid,PDO::PARAM_STR);
            
            $status = $result->execute();
        }
        echo $status;
    }
    
public function actionList(){
        
        $this->__common();
        $this->layout = "//layouts/main_other";
        
        Yii::app()->clientScript->registerCssFile(THEME_CSS_URL . '/chart.css');
        Yii::app()->clientScript->registerScriptFile(STATICS_URL . "/js/Highcharts/js/highcharts.js");
        Yii::app()->clientScript->registerScriptFile(STATICS_URL . "/js/Highcharts/js/modules/exporting.js");
        Yii::app()->clientScript->registerScriptFile(THEME_JS_URL . "/chart.js");

        $exam_id = $this->request->getParam('exam_id'); //考试
        $school_code = $this->request->getParam('school_code');  //学校
        $type = $this->request->getParam('type');  //科目
        $mp = $this->request->getParam('mp');  //科别
        $ptype = $this->request->getParam('ptype');  //类型
        
        //得到分数段规则
        $zExam = new zExam();
        $point = $zExam->_getPointObject();
        $rule_array = array();  //得到分数线
        
        $photo_image_data  = $photo_image_sj = array();
        $photo_image_data['categories'] = array('合计', '文科', '理科');
        $photo_image_data['lable'] = '人数';
        $photo_image_data['unit'] = '%';
        if(!empty($point)){
            $photo_image_data['ptype'][] = '本次';
            foreach($point as $pVal){
                $photo_image_data['ptype'][] = $pVal;   
            }
        }
        
        //得到(文理科)分数线
        $score = $zExam->_getEduScoreArray($exam_id);
        foreach($score as $sKey => $sVal){

            $rule_array['old'][$sKey] = $sVal['score_type2'];  //原规则分数（本二）
            if(!empty($point)){
                foreach ($point as $k => $val){
                    $list = "\$va=".$sVal['score_type2'].$val.";";
                    eval($list);  //运行字符串
                    $rule_array['new'][$sKey][$k] = $va;
                }
            }
        }

        //得到达C率
        $zExamRule = new ZExamRule();
        $garding_cid = $zExamRule->_getGradingCpoint();
        $garding_bid = $zExamRule->_getGradingBpoint();
        
        $gcdata = $gbdata = array();
        if ($garding_cid > 0) {
            //得到达标科目分数
            $gradingsql = 'SELECT * FROM "{{point_grading}}" WHERE "exam_id" = :exam_id AND "grading_id" = :g_id ';
            $gresult = Yii::app()->db->createCommand($gradingsql);
            $gresult->bindParam(':exam_id',$exam_id,PDO::PARAM_STR);
            $gresult->bindParam(':g_id', $garding_cid, PDO::PARAM_STR);
            $gradingdatac = $gresult->queryAll();
            if (!empty($gradingdatac)) {
                foreach ($gradingdatac as $gcVal) {
                    $gcdata[$gcVal['subject_id']] = $gcVal['score'];
                }
            }
        }
        //得到达B率
        if ($garding_bid > 0) {
            //得到达标科目分数
            $gradingsql = 'SELECT * FROM "{{point_grading}}" WHERE "exam_id" = :exam_id AND "grading_id" = :g_id ';
            $gresult = Yii::app()->db->createCommand($gradingsql);
            $gresult->bindParam(':exam_id', $exam_id, PDO::PARAM_STR);
            $gresult->bindParam(':g_id', $garding_bid, PDO::PARAM_STR);
            $gradingdatab = $gresult->queryAll();
            if (!empty($gradingdatab)) {
                foreach ($gradingdatab as $gbVal) {
                    $gbdata[$gbVal['subject_id']] = $gbVal['score'];
                }
            }
        }
        
        $zEdu = new ZEdu();
        
        //得到科目
        $subjectObject = $zEdu->_getSubjectObject();
        $gardingCArray = $zExamRule->_getExamGarding($exam_id, $garding_cid, $subjectObject); //得到想关类型分数C
        $gardingBArray = $zExamRule->_getExamGarding($exam_id, $garding_bid, $subjectObject); //得到想关类型分数B
        
        $school_array = array();
        //得到考试项目学校
        if(!empty($exam_id) && empty($school_code)){
            //得到考试项目对应学校
        	if ($this->user_role_list != 1) {
            	$school_array = $zExam->_getExamSchoolArray($exam_id,$zEdu,$this->user_school_list);
        	}else{
            $school_array = $zExam->_getExamSchoolArray($exam_id,$zEdu);
        	}
        }elseif(!empty($school_code)){
            $value = array();

            $school_info = $zEdu->_getSchool($school_code);
            $value['school_id']  = isset($school_info['school_id'])?$school_info['school_id']:'';
            $value['school_name'] = isset($school_info['school_name'])?$school_info['school_name']:'';
            $value['school_code'] = isset($school_info['school_code'])?$school_info['school_code']:'';        
            $school_array[]= $value;
        }

        $table1 = $table2 = $table3 = $table4 = $table5 = $table6 = '';
        
        $photo_other_array = $photo_data = $photo_db_data = $photo_people_num = array();

        //得到分数段科目对应的栏位
        $lwSubject = self::_getDBnum();
        
        //生成学校表格
        if(!empty($school_array)){
            
            $wk_point = isset($rule_array['old'][2])?$rule_array['old'][2]:0;  //文科分数线
            $lk_point = isset($rule_array['old'][1])?$rule_array['old'][1]:0;  //理科分数线

            $table3 = '<td align="center" rowspan="3" class="border_d" valign="middle"><span style="padding:0 5px;">本次划线</span></td>
                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">文科'.$wk_point.'</span></td>';
            $table4 = '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">理科'.$lk_point.'</span></td>';
            $table5 = '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">合计</span></td>';
            
            $school_exam_point = $f_new_data = array();
            $now_data_array = array();  //存储学校默认数据
            foreach ($school_array as $key => $sValue){

                $table1 .= '<th align="center" colspan="5" valign="middle" class="border_d"><span style="padding:0 5px;">'.$sValue['school_name'].'</span></th>';
                $table2 .= '<th align="center" valign="middle" class="border_d"><span style="padding:0 5px;">二本达线人数</span></th>
                    <th align="center" valign="middle" class="border_d"><span style="padding:0 5px;">二本达线比率</span></th>
                    <th align="center" valign="middle" class="border_d"><span style="padding:0 5px;">BC损耗人数</span></th>
                    <th align="center" valign="middle" class="border_d"><span style="padding:0 5px;">达线+BC人数</span></th>
                    <th align="center" valign="middle" class="border_d"><span style="padding:0 5px;">达线+BC比率</span></th>';
                
                $allPeople1 = $allPeople2 = $wkPeople = $lkPeople = 0;
                $wk_sh_people = $lk_sh_people = $a_sh_people = 0;
                $lk_db_people = $wk_db_people = $a_db_people = 0;
                $wk_bl = $lk_bl = 0;
                $wk_db_bl = $lk_db_bl = $a_db_bl = 0;
                
                $d_new_data = array();
                //得到数据
                $new_point_data = $zExamRule->_getExamPoint($exam_id, $sValue['school_code']);
                if (!empty($new_point_data)) {
                    foreach ($new_point_data as $nkey => $nvalue) {
                        $wndb = $lndb = $lsndb = $wsndb = 0;
                        //达B的类别科目信息
                        $dArray = $sArray = $pArray = array();
                        if(!empty($nvalue['disciplin_code'])){
                            if(isset($ddata[$nvalue['disciplin_code']])){
                                $dArray = $ddata[$nvalue['disciplin_code']];
                            }else{
                                $disciplinsql = 'SELECT "disciplin_id" FROM "{{disciplin}}" WHERE "disciplin_code" = :d_code ';
                                $dresult = Yii::app()->db->createCommand($disciplinsql);
                                $dresult->bindParam(':d_code',$nvalue['disciplin_code'],PDO::PARAM_STR);
                                $dArray = $dresult->queryRow();
                                $ddata[$nvalue['disciplin_code']] = $dArray;
                            }
                            //得到科别信息
                            if(!empty($dArray)){
                                if (isset($sdata[$dArray['disciplin_id']])) {
                                    $sArray = $sdata[$dArray['disciplin_id']];
                                } else {
                                    $disciplin_subjectsql = 'SELECT "subject_id" FROM "{{disciplin_subject}}" WHERE "disciplin_id" = :d_id ';
                                    $subjectids = Yii::app()->db->createCommand($disciplin_subjectsql);
                                    $subjectids->bindParam(':d_id', $dArray['disciplin_id'], PDO::PARAM_STR);
                                    $sArray = $subjectids->queryAll();
                                    $sdata[$dArray['disciplin_id']] = $sArray;
                                }
                            }
                        }
                        
                        $skf = $nvalue['ywf'] + $nvalue['sxf'] + $nvalue['yyf'];
                        $nvalue['apoint'] = $skf;
                        $d_new_data[$nvalue['disciplin_type']][] = $nvalue;
                        if ($nvalue['disciplin_type'] == 1) {
                            if ($skf >= $lk_point) {
                                $lkPeople += 1;
                                if(!empty($sArray)){
                                    foreach($sArray as $sVal){
                                        $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                        $pcpoint = isset($gcdata[$sVal['subject_id']]) ? $gcdata[$sVal['subject_id']] : 0;  //C分数线
                                        $pbpoint = isset($gbdata[$sVal['subject_id']]) ? $gbdata[$sVal['subject_id']] : 0;  //B分数线
                                        //得到达bc的人数
                                        $nPoint = isset($nvalue[$pkey]) ? $nvalue[$pkey] : 0; //科目分数
                                        if ($nPoint >= $pbpoint) {
                                            $lndb += 2;  //达到b
                                        } elseif ($nPoint >= $pcpoint) {
                                            $lndb += 1;  //达到c
                                        }
                                    }
                                    if ($lndb > 2) {
                                        $lk_db_people += 1;  //理科达到bc人数
                                }
                                }
                            }
                        } elseif ($nvalue['disciplin_type'] == 2) {
                            if ($skf >= $wk_point) {
                                $wkPeople += 1;
                                if(!empty($sArray)){
                                    foreach($sArray as $sVal){
                                        $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                        $pcpoint = isset($gcdata[$sVal['subject_id']]) ? $gcdata[$sVal['subject_id']] : 0;  //C分数线
                                        $pbpoint = isset($gbdata[$sVal['subject_id']]) ? $gbdata[$sVal['subject_id']] : 0;  //B分数线
                                            //得到未达b的人数
                                            $nPoint = isset($nvalue[$pkey])?$nvalue[$pkey]:0; //分数
                                            if ($nPoint >= $pbpoint) {
                                                $lndb += 2;  //达到b
                                            } elseif ($nPoint >= $pcpoint) {
                                                $lndb += 1;  //达到c
                                        }
                                    }
                                    if ($lndb > 2) {
                                        $wk_db_people += 1;  //文科达到bc人数
                                }
                                }
                            }
                        }
                    }
                }
                //在籍人数获取
                if($mp>0){
                    $memberShip = $zExamRule->_getMeshipArray($mp,$sValue['school_id']);
                $all_people_num = count($new_point_data); //学校总人数
                $allPeople1 = isset($d_new_data[1])?count($d_new_data[1]):0;
                $allPeople2 = isset($d_new_data[2])?count($d_new_data[2]):0;
                    if(!empty($memberShip)){
                        $a1 = isset($memberShip[2]) ? $memberShip[2] : 0;
                        if($a1>$allPeople1){
                            $allPeople1 = $a1;
                        }
                        $a2 = isset($memberShip[1]) ? $memberShip[1] : 0;
                        if($a2>$allPeople2){
                            $allPeople2 = $a2;
                        }
                        $all_people_num = $allPeople1 + $allPeople2;
                    }
                }else{
                    $all_people_num = count($new_point_data); //学校总人数
                    $allPeople1 = isset($d_new_data[1]) ? count($d_new_data[1]) : 0;
                    $allPeople2 = isset($d_new_data[2]) ? count($d_new_data[2]) : 0; 
                }
                $wk_sh_people = $wkPeople - $wk_db_people;
                $lk_sh_people = $lkPeople - $lk_db_people;
                $a_db_people = $wk_db_people + $lk_db_people;
                $a_sh_people = $lk_sh_people + $wk_sh_people;  //bc损耗
                $aPeople = $wkPeople + $lkPeople;   //达到分数线人数
                
                $lk_bl = ($allPeople1 > 0) ? sprintf('%.2f', ($lkPeople / $allPeople1) * 100) : 0;    //达线率
                $wk_bl = ($allPeople2>0)?sprintf('%.2f', ($wkPeople/$allPeople2) * 100):0;

                $point_data = array();
                if(!empty($new_point_data)){
                    $point_data = $zExamRule->_getExamPointNewArr($new_point_data);
                }

                $school_exam_point[$sValue['school_id']]['school_data'] = $point_data;
                $school_exam_point[$sValue['school_id']]['school_name'] = $sValue['school_name'];
                
                $a_bl = ($all_people_num >0) ? sprintf('%.2f', ($aPeople / $all_people_num) * 100) : 0;
                
                
                $wk_db_bl = ($wkPeople>0)?sprintf('%.2f', ($wk_db_people/$allPeople2)*100):0;
                $lk_db_bl = ($lkPeople>0)?sprintf('%.2f', ($lk_db_people/$allPeople1)*100):0;                
                $a_db_bl = ($all_people_num >0) ? sprintf('%.2f', ($a_db_people / $all_people_num) * 100) : 0;
                
                $photo_data[$sValue['school_id']] = array((float)$a_bl,(float)$wk_bl,(float)$lk_bl);  //图形显示数据
                $photo_db_data[$sValue['school_id']] = array((float)$a_db_bl,(float)$wk_db_bl,(float)$lk_db_bl);  //图形显示数据
                $photo_people_num[$sValue['school_id']] = $all_people_num;

                $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$wkPeople.'</span></td>
                            <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$wk_bl.'%</span></td>';
                $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$wk_sh_people.'</span></td>
                            <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$wk_db_people.'</span></td>';
                $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$wk_db_bl.'%</span></td>';

                $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$lkPeople.'</span></td>
                            <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$lk_bl.'%</span></td>';
                $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$lk_sh_people.'</span></td>
                            <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$lk_db_people.'</span></td>';
                $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$lk_db_bl.'%</span></td>';

                $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$aPeople.'</span></td>
                            <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$a_bl.'%</span></td>';
                $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$a_sh_people.'</span></td>
                            <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$a_db_people.'</span></td>';
                $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">'.$a_db_bl.'%</span></td>';
                //比例数据
                $now_data_array[$sValue['school_id']]['wk_num'] = $wkPeople;
                $now_data_array[$sValue['school_id']]['lk_num'] = $lkPeople;
                $now_data_array[$sValue['school_id']]['wks_num'] = $wk_sh_people;
                $now_data_array[$sValue['school_id']]['lks_num'] = $lk_sh_people;
                $now_data_array[$sValue['school_id']]['wkb_num'] = $wk_db_people;
                $now_data_array[$sValue['school_id']]['lkb_num'] = $lk_db_people;
            }

            $data = self::getPointTable($point, $rule_array, $school_exam_point, $gardingCArray, $gardingBArray, $gcdata, $gbdata, $photo_data, $photo_db_data,$now_data_array,$ptype,$mp);
            $table6 .= $data['table'];

            $photo_other_array = $data['data'];
        }
        
        $this->title = '分数线变化分析';
        $this->render('list',array(
            'rule_array'        => $rule_array,
            'school_array'      => $school_array,
            'table1'            => $table1,
            'table2'            => $table2,
            'table3'            => $table3,
            'table4'            => $table4,
            'table5'            => $table5,
            'table6'            => $table6,
           // 'photo_name'        => $photo_name,
           // 'photo_data'        => $photo_data,
            'exam_id'           => $exam_id,
            'school_id'         => $school_code,
            'ptype'     => $ptype,
            'mp'                => $mp,
            'photo_image_data'  => $photo_image_data,
            'photo_other_array' => $photo_other_array,
            'photo_people_num'  => $photo_people_num
        ));
    }
public function actionImport_list(){
        
	$this->__common();
        $exam_id = $this->request->getParam('exam_id'); //考试
        $school_code = $this->request->getParam('school_id');  //学校
        $ptype = $this->request->getParam('ptype');  //类型
        $mp = $this->request->getParam('mp'); //在籍人数

        $photo_name = $photo_data = array();
        
        //得到分数段规则
        $zExam = new zExam();
        $point = $zExam->_getPointObject();

        $rule_array = array();  //得到分数线
        
        //得到(文理科)分数线
        $score = $zExam->_getEduScoreArray($exam_id);
        foreach($score as $sKey => $sVal){

            $rule_array['old'][$sKey] = $sVal['score_type2'];  //原规则分数（本二）
            if(!empty($point)){
                foreach ($point as $k => $val){
                    $list = "\$va=".$sVal['score_type2'].$val.";";
                    eval($list);  //运行字符串
                    $rule_array['new'][$sKey][$k] = $va;
                }
            }
        }

        //得到达C率
        $zExamRule = new ZExamRule();
        $garding_cid = $zExamRule->_getGradingCpoint();
        $garding_bid = $zExamRule->_getGradingBpoint();
        $gcdata = $gbdata = array();
        if ($garding_cid > 0) {
            //得到达标科目分数
            $gradingsql = 'SELECT * FROM "{{point_grading}}" WHERE "exam_id" = :exam_id AND "grading_id" = :g_id ';
            $gresult = Yii::app()->db->createCommand($gradingsql);
            $gresult->bindParam(':exam_id',$exam_id,PDO::PARAM_STR);
            $gresult->bindParam(':g_id', $garding_cid, PDO::PARAM_STR);
            $gradingdatac = $gresult->queryAll();
            if (!empty($gradingdatac)) {
                foreach ($gradingdatac as $gcVal) {
                    $gcdata[$gcVal['subject_id']] = $gcVal['score'];
                }
            }
        }
        //得到达B率
        if ($garding_bid > 0) {
            //得到达标科目分数
            $gradingsql = 'SELECT * FROM "{{point_grading}}" WHERE "exam_id" = :exam_id AND "grading_id" = :g_id ';
            $gresult = Yii::app()->db->createCommand($gradingsql);
            $gresult->bindParam(':exam_id', $exam_id, PDO::PARAM_STR);
            $gresult->bindParam(':g_id', $garding_bid, PDO::PARAM_STR);
            $gradingdatab = $gresult->queryAll();
            if (!empty($gradingdatab)) {
                foreach ($gradingdatab as $gbVal) {
                    $gbdata[$gbVal['subject_id']] = $gbVal['score'];
                }
            }
        }
        
        //得到分数段科目对应的栏位
        $lwSubject = self::_getDBnum();
        
        $zEdu = new ZEdu();
        //得到科目
        $subjectObject = $zEdu->_getSubjectObject();
        $gardingCArray = $zExamRule->_getExamGarding($exam_id, $garding_cid, $subjectObject); //得到想关类型分数C
        $gardingBArray = $zExamRule->_getExamGarding($exam_id, $garding_bid, $subjectObject); //得到想关类型分数B  

        //得到考试项目学校
        if(!empty($exam_id) && empty($school_code)){
            //得到考试项目对应学校
            $school_array = $zExam->_getExamSchoolArray($exam_id,$zEdu);
        }elseif(!empty($school_code)){
            $value = array();

            $school_info = $zEdu->_getSchool($school_code);
            $value['school_id']  = isset($school_info['school_id'])?$school_info['school_id']:'';
            $value['school_name'] = isset($school_info['school_name'])?$school_info['school_name']:'';
            $value['school_code'] = isset($school_info['school_code'])?$school_info['school_code']:'';        
            $school_array[]= $value;
        }
        
        spl_autoload_unregister(array('YiiBase', 'autoload'));
        include_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/extensions/PHPExcel.php');
        include_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/extensions/PHPExcel/IOFactory.php');

        $objPHPExcel = new PHPExcel();
        //第一行
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '分数线');
        
        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
        $objPHPExcel->getActiveSheet(0)->mergeCells( 'A1:B2');
        
        $wk_point = isset($rule_array['old'][2])?$rule_array['old'][2]:"";  //文科分数线
        $lk_point = isset($rule_array['old'][1])?$rule_array['old'][1]:"";  //理科分数线
        
        if(!empty($school_array)){
            $i = 2;
            $list = $now_data_array = array();
            foreach ($school_array as $sValue) {

                $k = $j = '';
                $k1 = $k2 = $k3 = $kl1 = $kl2 = $kl3 = '';
                $ksnum = 0;
                if ($i == 2) {
                    $ks = $i + 4;  //开始
                    $js = $ks; //结束

                    $k1 = $i + 1;
                    $kl1 = self::_getXlsTitle($k1);
                    $k2 = $i + 2;
                    $kl2 = self::_getXlsTitle($k2);
                    $k3 = $i + 3;
                    $kl3 = self::_getXlsTitle($k3);

                    $ksnum = $i;
                    $k = self::_getXlsTitle($i);
                    $j = self::_getXlsTitle($js);

                    $i = $ks + 1;
                } else {

                    $ks += 1;  //开始
                    $jjs = $ks + 4; //结束

                    $k1 = $ks + 1;
                    $kl1 = self::_getXlsTitle($k1);
                    $k2 = $ks + 2;
                    $kl2 = self::_getXlsTitle($k2);
                    $k3 = $ks + 3;
                    $kl3 = self::_getXlsTitle($k3);

                    $ksnum = $ks;
                    $k = self::_getXlsTitle($ks);
                    $j = self::_getXlsTitle($jjs);

                    $i = $ks = $ks + 4;
                }

                $kst = $k . '1:' . $j . '1';
                $list[] = $kst;
                //第一行开始数据
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue($k . 1, $sValue['school_name']);

                //第二行开始数据
                $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue($k . 2, '二本达线人数')
                ->setCellValue($kl1 . 2, '二本达线比率')
                ->setCellValue($kl2 . 2, 'BC损耗人数')
                ->setCellValue($kl3 . 2, '达线+BC人数')
                ->setCellValue($j . 2, '达线+BC比率');
                
                $objPHPExcel->getActiveSheet(0)->mergeCells( $kst );
                
                $objPHPExcel->getActiveSheet()->getColumnDimension($k)->setWidth(25);
                $objPHPExcel->getActiveSheet()->getColumnDimension($kl1)->setWidth(25);
                $objPHPExcel->getActiveSheet()->getColumnDimension($kl2)->setWidth(25);
                $objPHPExcel->getActiveSheet()->getColumnDimension($kl3)->setWidth(25);
                $objPHPExcel->getActiveSheet()->getColumnDimension($j)->setWidth(25);
                
                
                //得到数据
                $allPeople1 = $allPeople2 = $wkPeople = $lkPeople = 0;
                $wk_bl = $lk_bl = 0;

                $d_new_data = array();
                //得到数据
                $new_point_data = $zExamRule->_getExamPoint($exam_id,$sValue['school_code']);
                $wk_sh_people = $lk_sh_people = $a_sh_people = 0;   
                $lk_db_people = $wk_db_people = $a_db_people = 0;
                if (!empty($new_point_data)) {
                    foreach ($new_point_data as $nkey => $nvalue) {
                        $wndb = $lndb = 0;
                        //达B的类别科目信息
                        $dArray = $sArray = $pArray = array();
                        if(!empty($nvalue['disciplin_code'])){
                            if(isset($ddata[$nvalue['disciplin_code']])){
                                $dArray = $ddata[$nvalue['disciplin_code']];
                            }else{
                                $disciplinsql = 'SELECT "disciplin_id" FROM "{{disciplin}}" WHERE "disciplin_code" = :d_code ';
                                $dresult = Yii::app()->db->createCommand($disciplinsql);
                                $dresult->bindParam(':d_code',$nvalue['disciplin_code'],PDO::PARAM_STR);
                                $dArray = $dresult->queryRow();
                                $ddata[$nvalue['disciplin_code']] = $dArray;
                            }
                            //得到科别信息
                            if(!empty($dArray)){
                                if (isset($sdata[$dArray['disciplin_id']])) {
                                    $sArray = $sdata[$dArray['disciplin_id']];
                                } else {
                                    $disciplin_subjectsql = 'SELECT "subject_id" FROM "{{disciplin_subject}}" WHERE "disciplin_id" = :d_id ';
                                    $subjectids = Yii::app()->db->createCommand($disciplin_subjectsql);
                                    $subjectids->bindParam(':d_id', $dArray['disciplin_id'], PDO::PARAM_STR);
                                    $sArray = $subjectids->queryAll();
                                    $sdata[$dArray['disciplin_id']] = $sArray;
                                }
                            }
                        }
                        
                        $skf = $nvalue['ywf'] + $nvalue['sxf'] + $nvalue['yyf'];
                        $nvalue['apoint'] = $skf;
                        $d_new_data[$nvalue['disciplin_type']][] = $nvalue;
                        if ($nvalue['disciplin_type'] == 1) {
                            if ($skf >= $lk_point) {
                                $lkPeople += 1;
                                if(!empty($sArray)){
                                    foreach($sArray as $sVal){
                                        $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                        $pcpoint = isset($gcdata[$sVal['subject_id']]) ? $gcdata[$sVal['subject_id']] : 0;  //C分数线
                                        $pbpoint = isset($gbdata[$sVal['subject_id']]) ? $gbdata[$sVal['subject_id']] : 0;  //B分数线
                                        //得到达bc的人数
                                        $nPoint = isset($nvalue[$pkey]) ? $nvalue[$pkey] : 0; //科目分数
                                        if ($nPoint >= $pbpoint) {
                                            $lndb += 2;  //达到b
                                        } elseif ($nPoint >= $pcpoint) {
                                            $lndb += 1;  //达到c
                                        }
                                    }
                                    if ($lndb > 2) {
                                        $lk_db_people += 1;  //理科达到bc人数
                                }
                                }
                            }
                        }elseif($nvalue['disciplin_type'] == 2){
                            if ($skf >= $wk_point) {
                                $wkPeople += 1;
                                if(!empty($sArray)){
                                    foreach($sArray as $sVal){
                                        $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                        $pcpoint = isset($gcdata[$sVal['subject_id']]) ? $gcdata[$sVal['subject_id']] : 0;  //C分数线
                                        $pbpoint = isset($gbdata[$sVal['subject_id']]) ? $gbdata[$sVal['subject_id']] : 0;  //B分数线

                                            //得到未达b的人数
                                            $nPoint = isset($nvalue[$pkey])?$nvalue[$pkey]:0; //分数
                                            if ($nPoint >= $pbpoint) {
                                                $lndb += 2;  //达到b
                                            } elseif ($nPoint >= $pcpoint) {
                                                $lndb += 1;  //达到c
                                        }
                                    }
                                    if ($lndb > 2) {
                                        $wk_db_people += 1;  //文科达到bc人数
                                }
                                }
                            }
                        }
                    }
                }
                $all_people_num = count($new_point_data); //学校总人数
                $allPeople1 = isset($d_new_data[1])?count($d_new_data[1]):0;
                $allPeople2 = isset($d_new_data[2])?count($d_new_data[2]):0;
                $aPeople = $wkPeople + $lkPeople;
                
                //在籍人数获取
                if($mp>0){
                    $memberShip = $zExamRule->_getMeshipArray($mp,$sValue['school_id']);
                    if(!empty($memberShip)){
                        $a1 = isset($memberShip[2]) ? $memberShip[2] : 0;
                        if($a1>$allPeople1){
                            $allPeople1 = $a1;
                        }
                        $a2 = isset($memberShip[1]) ? $memberShip[1] : 0;
                        if($a2>$allPeople2){
                            $allPeople2 = $a2;
                        }
                        $all_people_num = $allPeople1 + $allPeople2;
                    }
                }
                $point_data = array();
                if(!empty($new_point_data)){
                    $point_data = $zExamRule->_getExamPointNewArr($new_point_data);
                }

                $school_exam_point[$sValue['school_id']]['school_data'] = $point_data;
                $school_exam_point[$sValue['school_id']]['school_name'] = $sValue['school_name'];

                $lk_bl = ($allPeople1>0)?sprintf('%.2f', ($lkPeople/$allPeople1) * 100):0;    //达线率
                $wk_bl = ($allPeople2>0)?sprintf('%.2f', ($wkPeople/$allPeople2) * 100):0;
                $a_bl = ($all_people_num>0) ? sprintf('%.2f', ($aPeople/$all_people_num) * 100) : 0;
                
                $wk_sh_people = $wkPeople - $wk_db_people;
                $lk_sh_people = $lkPeople - $lk_db_people;
                $a_db_people = $wk_db_people + $lk_db_people;
                $a_sh_people = $lk_sh_people + $wk_sh_people;
                
                $wk_db_bl = ($wkPeople>0)?sprintf('%.2f', $wk_db_people/$allPeople2):0;
                $lk_db_bl = ($lkPeople>0)?sprintf('%.2f', $lk_db_people/$allPeople1):0;                
                $a_db_bl = ($all_people_num>0) ? sprintf('%.2f', $a_db_people/$all_people_num) : 0;
                
                //第三行开始数据
                $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue($k . 3, $wkPeople)
                ->setCellValue($kl1 . 3, $wk_bl)
                ->setCellValue($kl2 . 3, $wk_sh_people)
                ->setCellValue($kl3 . 3, $wk_db_people)
                ->setCellValue($j . 3, $wk_db_bl);
                
                $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue($k . 4, $lkPeople)
                ->setCellValue($kl1 . 4, $lk_bl)
                ->setCellValue($kl2 . 4, $lk_sh_people)
                ->setCellValue($kl3 . 4, $lk_db_people)
                ->setCellValue($j . 4, $lk_db_bl);
                
                $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue($k . 5, $aPeople)
                ->setCellValue($kl1 . 5, $a_bl)
                ->setCellValue($kl2 . 5, $a_sh_people)
                ->setCellValue($kl3 . 5, $a_db_people)
                ->setCellValue($j . 5, $a_db_bl);
                
                //比例数据
                $now_data_array[$sValue['school_id']]['wk_num'] = $wkPeople;
                $now_data_array[$sValue['school_id']]['lk_num'] = $lkPeople;
                $now_data_array[$sValue['school_id']]['wks_num'] = $wk_sh_people;
                $now_data_array[$sValue['school_id']]['lks_num'] = $lk_sh_people;
                $now_data_array[$sValue['school_id']]['wkb_num'] = $wk_db_people;
                $now_data_array[$sValue['school_id']]['lkb_num'] = $lk_db_people;
                $new_data_array = self::getPointTableXls($point, $rule_array, $school_exam_point,$gardingCArray, $gardingBArray, $gcdata, $gbdata,$now_data_array,$ptype,$mp);
                if(!empty($new_data_array)){
                    $ki = 6;
                    $ki1 = 7;
                    $kj = 8;

                    foreach($new_data_array as $pK => $pVal){
                         $wlist = "\$n_wk_point=".$wk_point.$pK.";";
                         eval($wlist);  //运行字符串
                         $llist = "\$n_lk_point=".$lk_point.$pK.";";
                         eval($llist);  //运行字符串
                        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$ki, $pK);
                        $kss = 'A'.$ki.':'.'A'.$kj;
                        $objPHPExcel->getActiveSheet(0)->mergeCells( $kss );

                        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$ki, '文科'.$n_wk_point);
                        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$ki1, '理科'.$n_lk_point);
                        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$kj, '合计'); 
                        
                        foreach($pVal as $sK => $sV){
                            
                           //第三行开始数据
                           $objPHPExcel->setActiveSheetIndex(0)
                           ->setCellValue($k . $ki, $sV['wkPeople'])
                           ->setCellValue($kl1 . $ki, $sV['wk_bl'])
                           ->setCellValue($kl2 . $ki, $sV['wk_sh_people'])
                           ->setCellValue($kl3 . $ki, $sV['wk_db_people'])
                           ->setCellValue($j . $ki, $sV['wk_db_bl']);

                           $objPHPExcel->setActiveSheetIndex(0)
                           ->setCellValue($k . $ki1, $sV['lkPeople'])
                           ->setCellValue($kl1 . $ki1, $sV['lk_bl'])
                           ->setCellValue($kl2 . $ki1, $sV['lk_sh_people'])
                           ->setCellValue($kl3 . $ki1, $sV['lk_db_people'])
                           ->setCellValue($j . $ki1, $sV['lk_db_bl']);

                           $objPHPExcel->setActiveSheetIndex(0)
                           ->setCellValue($k . $kj, $sV['aPeople'])
                           ->setCellValue($kl1 . $kj, $sV['ak_bl'])
                           ->setCellValue($kl2 . $kj, $sV['a_sh_people'])
                           ->setCellValue($kl3 . $kj, $sV['a_db_people'])
                           ->setCellValue($j . $kj, $sV['a_db_bl']);
                           
                        }
                        
                        $ki += 3;
                        $ki1 = $ki1 + 3;
                        $kj = $kj + 3;
                    }
                }
                
            }
            
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A3', '本次划线');
            $objPHPExcel->getActiveSheet(0)->mergeCells( 'A3:A5' );
            
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B3', '文科'.$wk_point);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B4', '理科'.$lk_point);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B5', '合计');  
            
            $objPHPExcel->setActiveSheetIndex(0);
            $file_nams = "分数线变化分析";
            $file_nams .= ".xls";

            if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
                $file_nams = urlencode($file_nams);
                $file_nams = str_replace("+", "%20", $file_nams); // 替换空格
            }
            ob_end_clean();
            header("Content-Type: application/vnd.ms-excel;charset=utf-8");
            header("Content-Disposition: attachment; filename=" . $file_nams);
            header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
            header('Expires:0');
            header('Pragma:public');

            $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
            $objWriter->save('php://output');

            Yii::app()->end();
            spl_autoload_register(array('YiiBase', 'autoload'));
            exit;
        }else{
            echo 1;
            exit;
        }
             
    }
    /**
     * 计算出xls 的标头
     * 
     * @version 1.0
     * @date 2014-01-25
     */
    protected function _getXlsTitle($num) {
        
        $data = array(0=>'A',1=>'B',2=>'C',3=>'D',4=>'E',5=>'F',6=>'G',7=>'H',8=>'I',9=>'J',10=>'K',11=>'L',12=>'M',13=>'N',14=>'O',15=>'P',16=>'Q',17=>'R',18=>'S',19=>'T',20=>'U',21=>'V',22=>'W',23=>'X',24=>'Y',25=>'Z');

        $d = 26;
        $z = floor($num/$d);
        
        $key = '';
        if($z>0){
            $y = floor($num%$d);
            if($y==0){
                $key = $data[$y].$data[$z-1];
            }else{
                $key = $data[$z-1].$data[$y];
            }
        }else{
            $key = $data[$num];
        }
        return $key;
    }
    /**
     * 统计数据
     * 
     * @param $point  规则
     * @param $rule_array 新规则
     * @param $school_array 学校
     * @param $photo_data 图表
     * 
     * @return array
     * 
     * @version 1.0
     * @date 2013-12-29
     * @author jinyue.wang
     */
    protected function getPointTable($point,$rule_array,$school_exam_point,$gardingCArray,$gardingBArray,$gcdata,$gbdata,$photo_datas,$photo_db_datas,$now_data_array,$ptype,$mp){
        
        $table = '';
        $photo_new_data = $photo_other_data = $photo_data = $photo_db_data = $photo_new_db_data = array();
        if (!empty($point)) {
            
            //得到分数段科目对应的栏位
            $lwSubject = self::_getDBnum();
            $zExamRule = new ZExamRule();
            
            $photo_data[] = $photo_datas;
            $photo_db_data[] = $photo_db_datas;
            foreach ($point as $key => $value) {

                $lk_point = isset($rule_array['new'][1][$key])?$rule_array['new'][1][$key]:0;
                $wk_point = isset($rule_array['new'][2][$key])?$rule_array['new'][2][$key]:0;
                
                $table3 = '<td align="center" class="border_d" valign="middle" ><span style="padding:0 5px;">文科' . $wk_point . '</span></td>';
                $table4 = '<td align="center" class="border_d" valign="middle" ><span style="padding:0 5px;">理科' . $lk_point . '</span></td>';
                $table5 = '<td align="center" class="border_d" valign="middle" ><span style="padding:0 5px;">合计</span></td>';

                //学校成绩显示
                if (!empty($school_exam_point)) {
                    foreach ($school_exam_point as $sKey => $point_data) {
                        
                        $allPeople1 = $allPeople2 = $wkPeople = $lkPeople = 0;
                        $wk_bl = $lk_bl = 0;
                        $lk_db_people = $wk_db_people = $a_db_people = 0;
                        $wk_sh_people = $lk_sh_people = $a_sh_people = 0;
                        
                        //$allPeople1 = isset($point_data['school_data']['data'][1])?count($point_data['school_data']['data'][1]):0;
                       //$allPeople2 = isset($point_data['school_data']['data'][2])?count($point_data['school_data']['data'][2]):0;

                        if (isset($point_data['school_data'][1])) {
                            $allPeople1 = count($point_data['school_data'][1]);  //理科总人数
                            foreach ($point_data['school_data'][1] as $lkey => $nvalue) {
                                if ($nvalue['zf'] >= $lk_point) {
                                    $lkPeople += 1;
 
                                    $wndb = $lndb = 0;
                                    //达B的类别科目信息
                                    $dArray = $sArray = $pArray = array();
                                    if(!empty($nvalue['disciplin_code'])){
                                        if(isset($ddata[$nvalue['disciplin_code']])){
                                            $dArray = $ddata[$nvalue['disciplin_code']];
                                        }else{
                                            $disciplinsql = 'SELECT "disciplin_id" FROM "{{disciplin}}" WHERE "disciplin_code" = :d_code ';
                                            $dresult = Yii::app()->db->createCommand($disciplinsql);
                                            $dresult->bindParam(':d_code',$nvalue['disciplin_code'],PDO::PARAM_STR);
                                            $dArray = $dresult->queryRow();
                                            $ddata[$nvalue['disciplin_code']] = $dArray;
                                        }
                                        //得到科别信息
                                        if(!empty($dArray)){
                                            if (isset($sdata[$dArray['disciplin_id']])) {
                                                $sArray = $sdata[$dArray['disciplin_id']];
                                            } else {
                                                $disciplin_subjectsql = 'SELECT "subject_id" FROM "{{disciplin_subject}}" WHERE "disciplin_id" = :d_id ';
                                                $subjectids = Yii::app()->db->createCommand($disciplin_subjectsql);
                                                $subjectids->bindParam(':d_id', $dArray['disciplin_id'], PDO::PARAM_STR);
                                                $sArray = $subjectids->queryAll();
                                                $sdata[$dArray['disciplin_id']] = $sArray;
                                            }
                                        }
                                    }
                                    
                                    if(!empty($sArray)){
                                        foreach($sArray as $sVal){
                                            $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                            $pcpoint = isset($gcdata[$sVal['subject_id']])?$gcdata[$sVal['subject_id']]:0;  //C分数线
                                            $pbpoint = isset($gbdata[$sVal['subject_id']])?$gbdata[$sVal['subject_id']]:0;  //B分数线
                                            //得到达bc的人数
                                            $nPoint = isset($nvalue[$pkey])?$nvalue[$pkey]:0; //科目分数
                                            if($nPoint>=$pbpoint){
                                                $lndb += 2;  //达到b
                                            }elseif($nPoint>=$pcpoint){
                                                $lndb += 1;  //达到c
                                            }
                                        }
                                        if($lndb>2){
                                            $lk_db_people += 1;  //理科达到bc人数
                                    }
                                    }
                                }
                            }
                        }
                        if (isset($point_data['school_data'][2])) {
                            $allPeople2 = count($point_data['school_data'][2]);  //文科科总人数
                            foreach ($point_data['school_data'][2] as $wkey => $nvalue) {
                                if ($nvalue['zf'] >= $wk_point) {
                                    $wkPeople += 1;
                                    $wndb = $lndb = 0;
                                    //达B的类别科目信息
                                    $dArray = $sArray = $pArray = array();
                                    if(!empty($nvalue['disciplin_code'])){
                                        if(isset($ddata[$nvalue['disciplin_code']])){
                                            $dArray = $ddata[$nvalue['disciplin_code']];
                                        }else{
                                            $disciplinsql = 'SELECT "disciplin_id" FROM "{{disciplin}}" WHERE "disciplin_code" = :d_code ';
                                            $dresult = Yii::app()->db->createCommand($disciplinsql);
                                            $dresult->bindParam(':d_code',$nvalue['disciplin_code'],PDO::PARAM_STR);
                                            $dArray = $dresult->queryRow();
                                            $ddata[$nvalue['disciplin_code']] = $dArray;
                                        }
                                        //得到科别信息
                                        if(!empty($dArray)){
                                            if (isset($sdata[$dArray['disciplin_id']])) {
                                                $sArray = $sdata[$dArray['disciplin_id']];
                                            } else {
                                                $disciplin_subjectsql = 'SELECT "subject_id" FROM "{{disciplin_subject}}" WHERE "disciplin_id" = :d_id ';
                                                $subjectids = Yii::app()->db->createCommand($disciplin_subjectsql);
                                                $subjectids->bindParam(':d_id', $dArray['disciplin_id'], PDO::PARAM_STR);
                                                $sArray = $subjectids->queryAll();
                                                $sdata[$dArray['disciplin_id']] = $sArray;
                                            }
                                        }
                                    }
                                    
                                    if(!empty($sArray)){
                                        foreach($sArray as $sVal){
                                            $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                            $pcpoint = isset($gcdata[$sVal['subject_id']])?$gcdata[$sVal['subject_id']]:0;  //C分数线
                                            $pbpoint = isset($gbdata[$sVal['subject_id']])?$gbdata[$sVal['subject_id']]:0;  //B分数线

                                                //得到未达b的人数
                                                $nPoint = isset($nvalue[$pkey])?$nvalue[$pkey]:0; //分数
                                                if($nPoint>=$pbpoint){
                                                    $lndb += 2;  //达到b
                                                }elseif($nPoint>=$pcpoint){
                                                    $lndb += 1;  //达到c
                                            }
                                        }
                                        if($lndb>2){
                                            $wk_db_people += 1;  //文科达到bc人数
                                    }
                                    }
                                }
                            }
                        }
                        
                        //在籍人数获取
                        if($mp>0){
                            $memberShip = $zExamRule->_getMeshipArray($mp,$sKey);
                            if(!empty($memberShip)){
                                $a1 = isset($memberShip[2]) ? $memberShip[2] : 0;
                                if($a1>$allPeople1){
                                    $allPeople1 = $a1;
                                }
                                $a2 = isset($memberShip[1]) ? $memberShip[1] : 0;
                                if($a2>$allPeople2){
                                    $allPeople2 = $a2;
                                }
                            }
                        }
                        $allNum = $allPeople1 + $allPeople2;  //总人数
                        
                        $lk_bl = ($allPeople1>0) ? sprintf('%.2f', ($lkPeople / $allPeople1)*100) : 0;
                        $wk_bl = ($allPeople2>0) ? sprintf('%.2f', ($wkPeople / $allPeople2)*100) : 0;

                        $aPeople = $wkPeople + $lkPeople;  //总达线人数
                        $a_bl = ($allNum > 0) ? sprintf('%.2f', ($aPeople / $allNum)*100) : 0;
                        
                        $wk_sh_people = $wkPeople - $wk_db_people;
                        $lk_sh_people = $lkPeople - $lk_db_people;
                        $a_db_people = $wk_db_people + $lk_db_people;
                        $a_sh_people = $lk_sh_people + $wk_sh_people;

                        $wk_db_bl = ($wkPeople > 0) ? sprintf('%.2f', ($wk_db_people / $allPeople2)*100) : 0;
                        $lk_db_bl = ($lkPeople > 0) ? sprintf('%.2f', ($lk_db_people / $allPeople1)*100) : 0;
                        $a_db_bl = ($allNum > 0) ? sprintf('%.2f', ($a_db_people / $allNum)*100) : 0;
 
                        $photo_new_data[$sKey] = array((float)$a_bl,(float)$wk_bl,(float)$lk_bl);  //图形显示数据
                        $photo_new_db_data[$sKey] = array((float)$a_db_bl,(float)$wk_db_bl,(float)$lk_db_bl);  //图形显示数据
                        
                        //增肌人数重新计算
                        $duan_school_num = isset($now_data_array[$sKey]) ? $now_data_array[$sKey] : array();
                        if($ptype == 2){
                            $d_wk_people = isset($duan_school_num['wk_num']) ? $duan_school_num['wk_num'] : 0;
                            $d_lk_people = isset($duan_school_num['lk_num']) ? $duan_school_num['lk_num'] : 0;
                            $d_wks_people = isset($duan_school_num['wks_num']) ? $duan_school_num['wks_num'] : 0;
                            $d_lks_people = isset($duan_school_num['lks_num']) ? $duan_school_num['lks_num'] : 0;
                            $d_wkb_people = isset($duan_school_num['wkb_num']) ? $duan_school_num['wkb_num'] : 0;
                            $d_lkb_people = isset($duan_school_num['lkb_num']) ? $duan_school_num['lkb_num'] : 0;
                            $c_wk_people = $wkPeople - $d_wk_people;
                            $c_lk_people = $lkPeople - $d_lk_people;
                            $c_ak_people = $c_wk_people + $c_lk_people;
                            $c_wks_people = $wk_sh_people - $d_wks_people;
                            $c_lks_people = $lk_sh_people - $d_lks_people;
                            $c_aks_people = $c_wks_people + $c_lks_people;
                            $c_wkb_people = $wk_db_people - $d_wkb_people;
                            $c_lkb_people = $lk_db_people - $d_lkb_people;
                            $c_akb_people = $c_wkb_people + $c_lkb_people;
                            $c_wk_bl = ($allPeople2 > 0) ? sprintf('%.2f', ($c_wk_people / $allPeople2) * 100) : 0;
                            $c_lk_bl = ($allPeople1 > 0) ? sprintf('%.2f', ($c_lk_people / $allPeople1) * 100) : 0;
                            $c_ak_bl = ($allNum > 0) ? sprintf('%.2f', ($c_ak_people / $allNum) * 100) : 0;
                            
                            $c_wkb_bl = ($allPeople2 > 0) ? sprintf('%.2f', ($c_wkb_people / $allPeople2) * 100) : 0;
                            $c_lkb_bl = ($allPeople1 > 0) ? sprintf('%.2f', ($c_lkb_people / $allPeople1) * 100) : 0;
                            $c_akb_bl = ($allNum > 0) ? sprintf('%.2f', ($c_akb_people / $allNum) * 100) : 0;
                            $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_wk_people . '</span></td>
                                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_wk_bl . '%</span></td>';
                            $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_wks_people . '</span></td>
                                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_wkb_people . '</span></td>';
                            $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_wkb_bl . '%</span></td>';
                            $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_lk_people . '</span></td>
                                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_lk_bl . '%</span></td>';
                            $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_lks_people . '</span></td>
                                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_lkb_people . '</span></td>';
                            $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_lkb_bl . '%</span></td>';
                            $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_ak_people . '</span></td>
                                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_ak_bl . '%</span></td>';
                            $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_aks_people . '</span></td>
                                        <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_akb_people . '</span></td>';
                            $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $c_akb_bl . '%</span></td>';
                        }else{
                        $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $wkPeople . '</span></td>
                                    <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $wk_bl . '%</span></td>';
                        $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $wk_sh_people . '</span></td>
                                    <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $wk_db_people . '</span></td>';
                        $table3 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $wk_db_bl . '%</span></td>';

                        $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $lkPeople . '</span></td>
                                    <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $lk_bl . '%</span></td>';
                        $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $lk_sh_people . '</span></td>
                                    <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $lk_db_people . '</span></td>';
                        $table4 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $lk_db_bl . '%</span></td>';

                        $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $aPeople . '</span></td>
                                    <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $a_bl . '%</span></td>';
                        $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $a_sh_people . '</span></td>
                                    <td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $a_db_people . '</span></td>';
                        $table5 .= '<td align="center" class="border_d" valign="middle"><span style="padding:0 5px;">' . $a_db_bl . '%</span></td>';
                        }
                    }
                }
                
                $photo_data[] = $photo_new_data;
                $photo_db_data[] = $photo_new_db_data;
                        
                $table .= '<tr height="38">
                    <td align="center" rowspan="3" class="border_d" valign="middle"><span style="padding:0 5px;">' . $value . '</span></td>' . $table3 . '</tr>';
                $table .= '<tr height="38">' . $table4 . '</tr>';
                $table .= '<tr height="38">' . $table5 . '</tr>';
                
            }
        }
        
        $flash_data = array();
        $flash_data['dx_data'] = $photo_data;
        $flash_data['db_data'] = $photo_db_data;
        
        $new_data['table'] = $table;
        $new_data['data'] = $flash_data;
        
        return $new_data;
    }
    protected function getPointTableXls($point, $rule_array, $school_exam_point, $gardingCArray, $gardingBArray, $gcdata, $gbdata,$now_data_array,$ptype,$mp) {
        $table = '';
        $new_data_array = array();

        $zExamRule = new ZExamRule(); 
        //得到分数段科目对应的栏位
        $lwSubject = self::_getDBnum();
        if (!empty($point)) {
            foreach ($point as $key => $value) {

                $lk_point = isset($rule_array['new'][1][$key])?$rule_array['new'][1][$key]:0;
                $wk_point = isset($rule_array['new'][2][$key])?$rule_array['new'][2][$key]:0;

                //学校成绩显示

                if (!empty($school_exam_point)) {
                    foreach ($school_exam_point as $sKey => $point_data) {
                        
                        $allPeople1 = $allPeople2 = $wkPeople = $lkPeople = 0;
                        $wk_bl = $lk_bl = 0;

                        $wk_sh_people = $lk_sh_people = $a_sh_people = 0;
                        $lk_db_people = $wk_db_people = $a_db_people = 0;
                        $allPeople1 = isset($point_data['school_data'][1])?count($point_data['school_data'][1]):0;
                        $allPeople2 = isset($point_data['school_data'][2])?count($point_data['school_data'][2]):0;

                        if (isset($point_data['school_data'][1])) {
                            $allPeople1 = count($point_data['school_data'][1]);  //理科总人数
                            foreach ($point_data['school_data'][1] as $lkey => $nvalue) {
                                if ($nvalue['zf'] >= $lk_point) {
                                    $lkPeople += 1;
 
                                    $wndb = $lndb = 0;
                                    //达B的类别科目信息
                                    $dArray = $sArray = $pArray = array();
                                    if(!empty($nvalue['disciplin_code'])){
                                        if(isset($ddata[$nvalue['disciplin_code']])){
                                            $dArray = $ddata[$nvalue['disciplin_code']];
                                        }else{
                                            $disciplinsql = 'SELECT "disciplin_id" FROM "{{disciplin}}" WHERE "disciplin_code" = :d_code ';
                                            $dresult = Yii::app()->db->createCommand($disciplinsql);
                                            $dresult->bindParam(':d_code',$nvalue['disciplin_code'],PDO::PARAM_STR);
                                            $dArray = $dresult->queryRow();
                                            $ddata[$nvalue['disciplin_code']] = $dArray;
                                        }
                                        //得到科别信息
                                        if(!empty($dArray)){
                                            if (isset($sdata[$dArray['disciplin_id']])) {
                                                $sArray = $sdata[$dArray['disciplin_id']];
                                            } else {
                                                $disciplin_subjectsql = 'SELECT "subject_id" FROM "{{disciplin_subject}}" WHERE "disciplin_id" = :d_id ';
                                                $subjectids = Yii::app()->db->createCommand($disciplin_subjectsql);
                                                $subjectids->bindParam(':d_id', $dArray['disciplin_id'], PDO::PARAM_STR);
                                                $sArray = $subjectids->queryAll();
                                                $sdata[$dArray['disciplin_id']] = $sArray;
                                            }
                                        }
                                    }

                                    if(!empty($sArray)){
                                        foreach($sArray as $sVal){
                                            $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                            $pcpoint = isset($gcdata[$sVal['subject_id']]) ? $gcdata[$sVal['subject_id']] : 0;  //C分数线
                                            $pbpoint = isset($gbdata[$sVal['subject_id']]) ? $gbdata[$sVal['subject_id']] : 0;  //B分数线
                                            //得到达bc的人数
                                            $nPoint = isset($nvalue[$pkey]) ? $nvalue[$pkey] : 0; //科目分数
                                            if ($nPoint >= $pbpoint) {
                                                $lndb += 2;  //达到b
                                            } elseif ($nPoint >= $pcpoint) {
                                                $lndb += 1;  //达到c
                                                }
                                            }
                                        if ($lndb > 2) {
                                            $lk_db_people += 1;  //理科达到bc人数
                                        }
                                    }
                                    }
                                }
                            }

                        if (isset($point_data['school_data'][2])) {
                            $allPeople2 = count($point_data['school_data'][2]);  //理科总人数
                            foreach ($point_data['school_data'][2] as $wkey => $nvalue) {
                                if ($nvalue['zf'] >= $wk_point) {
                                    $wkPeople += 1;
                                    $wndb = $lndb = 0;
                                    //达B的类别科目信息
                                    $dArray = $sArray = $pArray = array();
                                    if(!empty($nvalue['disciplin_code'])){
                                        if(isset($ddata[$nvalue['disciplin_code']])){
                                            $dArray = $ddata[$nvalue['disciplin_code']];
                                        }else{
                                            $disciplinsql = 'SELECT "disciplin_id" FROM "{{disciplin}}" WHERE "disciplin_code" = :d_code ';
                                            $dresult = Yii::app()->db->createCommand($disciplinsql);
                                            $dresult->bindParam(':d_code',$nvalue['disciplin_code'],PDO::PARAM_STR);
                                            $dArray = $dresult->queryRow();
                                            $ddata[$nvalue['disciplin_code']] = $dArray;
                                        }
                                        //得到科别信息
                                        if(!empty($dArray)){
                                            if (isset($sdata[$dArray['disciplin_id']])) {
                                                $sArray = $sdata[$dArray['disciplin_id']];
                                            } else {
                                                $disciplin_subjectsql = 'SELECT "subject_id" FROM "{{disciplin_subject}}" WHERE "disciplin_id" = :d_id ';
                                                $subjectids = Yii::app()->db->createCommand($disciplin_subjectsql);
                                                $subjectids->bindParam(':d_id', $dArray['disciplin_id'], PDO::PARAM_STR);
                                                $sArray = $subjectids->queryAll();
                                                $sdata[$dArray['disciplin_id']] = $sArray;
                                            }
                                        }
                                    }

                                    if(!empty($sArray)){
                                        foreach($sArray as $sVal){
                                            $pkey = isset($lwSubject[$sVal['subject_id']])?$lwSubject[$sVal['subject_id']]:''; //科目栏位
                                            $pcpoint = isset($gcdata[$sVal['subject_id']]) ? $gcdata[$sVal['subject_id']] : 0;  //C分数线
                                            $pbpoint = isset($gbdata[$sVal['subject_id']]) ? $gbdata[$sVal['subject_id']] : 0;  //B分数线

                                                //得到未达b的人数
                                                $nPoint = isset($nvalue[$pkey])?$nvalue[$pkey]:0; //分数
                                                if ($nPoint >= $pbpoint) {
                                                    $lndb += 2;  //达到b
                                                } elseif ($nPoint >= $pcpoint) {
                                                    $lndb += 1;  //达到c
                                            }
                                        }
                                        if ($lndb > 2) {
                                            $wk_db_people += 1;  //文科达到bc人数
                                    }
                                    }
                                }
                            }
                        }
                        
                        //在籍人数获取
                        if($mp>0){
                            $memberShip = $zExamRule->_getMeshipArray($mp,$sKey);
                            if(!empty($memberShip)){
                                $a1 = isset($memberShip[2]) ? $memberShip[2] : 0;
                                if($a1>$allPeople1){
                                    $allPeople1 = $a1;
                                }
                                $a2 = isset($memberShip[1]) ? $memberShip[1] : 0;
                                if($a2>$allPeople2){
                                    $allPeople2 = $a2;
                                }
                            }
                        }
                        $all_people_num = $allPeople1 + $allPeople2;
                        
                        $lk_bl = ($allPeople1>0) ? sprintf('%.2f', ($lkPeople / $allPeople1)*100) : 0;
                        $wk_bl = ($allPeople2>0) ? sprintf('%.2f', ($wkPeople / $allPeople2)*100) : 0;

                        $aPeople = $wkPeople + $lkPeople;
                        $a_bl = ($all_people_num>0) ? sprintf('%.2f', ($aPeople / $all_people_num)*100) : 0;
                        
                        $wk_sh_people = $wkPeople - $wk_db_people;
                        $lk_sh_people = $lkPeople - $lk_db_people;
                        $a_db_people = $wk_db_people + $lk_db_people;
                        $a_sh_people = $lk_sh_people + $wk_sh_people;

                        $wk_db_bl = ($allPeople2 > 0) ? sprintf('%.2f', ($wk_db_people / $allPeople2)*100) : 0;
                        $lk_db_bl = ($allPeople1 > 0) ? sprintf('%.2f', ($lk_db_people / $allPeople1)*100) : 0;
                        $a_db_bl = ($all_people_num>0) ? sprintf('%.2f', ($a_db_people / $all_people_num)*100) : 0;
                        //增肌人数重新计算
                        $duan_school_num = isset($now_data_array[$sKey]) ? $now_data_array[$sKey] : array();
                        if($ptype == 2){
                            $d_wk_people = isset($duan_school_num['wk_num']) ? $duan_school_num['wk_num'] : 0;
                            $d_lk_people = isset($duan_school_num['lk_num']) ? $duan_school_num['lk_num'] : 0;
                            $d_wks_people = isset($duan_school_num['wks_num']) ? $duan_school_num['wks_num'] : 0;
                            $d_lks_people = isset($duan_school_num['lks_num']) ? $duan_school_num['lks_num'] : 0;
                            $d_wkb_people = isset($duan_school_num['wkb_num']) ? $duan_school_num['wkb_num'] : 0;
                            $d_lkb_people = isset($duan_school_num['lkb_num']) ? $duan_school_num['lkb_num'] : 0;
                            $c_wk_people = $wkPeople - $d_wk_people;
                            $c_lk_people = $lkPeople - $d_lk_people;
                            $c_ak_people = $c_wk_people + $c_lk_people;
                            $c_wks_people = $wk_sh_people - $d_wks_people;
                            $c_lks_people = $lk_sh_people - $d_lks_people;
                            $c_aks_people = $c_wks_people + $c_lks_people;
                            $c_wkb_people = $wk_db_people - $d_wkb_people;
                            $c_lkb_people = $lk_db_people - $d_lkb_people;
                            $c_akb_people = $c_wkb_people + $c_lkb_people;
                            $c_wk_bl = ($allPeople2 > 0) ? sprintf('%.2f', ($c_wk_people / $allPeople2)*100) : 0;
                            $c_lk_bl = ($allPeople1 > 0) ? sprintf('%.2f', ($c_lk_people / $allPeople1)*100) : 0;
                            $c_ak_bl = ($all_people_num > 0) ? sprintf('%.2f', ($c_akb_people / $all_people_num)*100) : 0;
                            $c_wkb_bl  = ($allPeople2 > 0) ? sprintf('%.2f', ($c_wkb_people / $allPeople2)*100) : 0;
                            $c_lkb_bl = ($allPeople1 > 0) ? sprintf('%.2f', ($c_lkb_people / $allPeople1)*100) : 0;
                            $c_akb_bl = ($all_people_num > 0) ? sprintf('%.2f', ($c_akb_people / $all_people_num)*100) : 0;
                            
                            $new_data_array[$value][$point_data['school_name']]['wkPeople'] = $c_wk_people;
                            $new_data_array[$value][$point_data['school_name']]['lkPeople'] = $c_lk_people;
                            $new_data_array[$value][$point_data['school_name']]['aPeople'] = $c_ak_people;
                            $new_data_array[$value][$point_data['school_name']]['wk_bl'] = $c_wk_bl;
                            $new_data_array[$value][$point_data['school_name']]['lk_bl'] = $c_lk_bl;
                            $new_data_array[$value][$point_data['school_name']]['ak_bl'] = $c_ak_bl;
                            $new_data_array[$value][$point_data['school_name']]['wk_sh_people'] = $c_wks_people;
                            $new_data_array[$value][$point_data['school_name']]['lk_sh_people'] = $c_lks_people;
                            $new_data_array[$value][$point_data['school_name']]['a_sh_people'] = $c_aks_people;
                            $new_data_array[$value][$point_data['school_name']]['wk_db_people'] = $c_wkb_people;
                            $new_data_array[$value][$point_data['school_name']]['lk_db_people'] = $c_lkb_people;
                            $new_data_array[$value][$point_data['school_name']]['a_db_people'] = $c_akb_people;
                            $new_data_array[$value][$point_data['school_name']]['wk_db_bl'] = $c_wkb_bl;
                            $new_data_array[$value][$point_data['school_name']]['lk_db_bl'] = $c_lkb_bl;
                            $new_data_array[$value][$point_data['school_name']]['a_db_bl'] = $c_akb_bl;
                        }else{
                        $new_data_array[$value][$point_data['school_name']]['wkPeople'] = $wkPeople;
                        $new_data_array[$value][$point_data['school_name']]['lkPeople'] = $lkPeople;
                        $new_data_array[$value][$point_data['school_name']]['aPeople'] = $aPeople;
                        $new_data_array[$value][$point_data['school_name']]['wk_bl'] = $wk_bl;
                        $new_data_array[$value][$point_data['school_name']]['lk_bl'] = $lk_bl;
                        $new_data_array[$value][$point_data['school_name']]['ak_bl'] = $a_bl;
                        $new_data_array[$value][$point_data['school_name']]['wk_sh_people'] = $wk_sh_people;
                        $new_data_array[$value][$point_data['school_name']]['lk_sh_people'] = $lk_sh_people;
                        $new_data_array[$value][$point_data['school_name']]['a_sh_people'] = $a_sh_people;
                        $new_data_array[$value][$point_data['school_name']]['wk_db_people'] = $wk_db_people;
                        $new_data_array[$value][$point_data['school_name']]['lk_db_people'] = $lk_db_people;
                        $new_data_array[$value][$point_data['school_name']]['a_db_people'] = $a_db_people;
                        $new_data_array[$value][$point_data['school_name']]['wk_db_bl'] = $wk_db_bl;
                        $new_data_array[$value][$point_data['school_name']]['lk_db_bl'] = $lk_db_bl;
                        $new_data_array[$value][$point_data['school_name']]['a_db_bl'] = $a_db_bl;
                        }
                        
                    }
                }
                
            }
        }
        return $new_data_array;
    }
    	/**
	* @ 批量删除学段
	* @ yindebin
	* @ 2014-01-06 pm
	*/
	public function actionDelete_all(){
		$id = Yii::app ()->request->getparam ( 'id' );
		if (! empty ( $id )) {
            $delete = 'DELETE FROM {{points_difference}} WHERE pd_id IN (' . $id . ')';
			$query = Yii::app()->db->createCommand($delete)->execute();
			echo 1;
		}else{
			echo 2;
		}
	}	
    /**
     * 根据考试得到相关学校
     * 
     * @author jinyue.wang
     * @version 1.0
     * @date 2014-01-22
     */
    public function actionAjax_get_school() {
        $this->__common();
        $exam_id = $this->request->getParam('exam_id');
        $list = "<option value=''>请选择</option>";
        if ($exam_id > 0) {
            $zEdu = new ZEdu();
            $zExam = new zExam();
            //得到考试项目对应学校
        	if ($this->user_role_list != 1) {
            	$school_array = $zExam->_getExamSchoolArray($exam_id,$zEdu,$this->user_school_list);
        	}else{
            $school_array = $zExam->_getExamSchoolArray($exam_id, $zEdu);
        	}
            if (!empty($school_array)) {
                foreach ($school_array as $key => $value) {
                    $list .= "<option value='" . $value['school_code'] . "'>" . $value['school_name'] . "</option>";
                }
            }
            echo $list;
        }
    }
    
/**
     * 得到2B率
     * 
     * @version 1.0
     * @date 2014-02-16
     */
    protected function _getDBnum() {
        //解决分数问题对应的科目id（前提科目名称必须对应）
        $pointObject = array(
            '物理' => 'wlf',
            '化学' => 'hxf',
            '生物' => 'swf',
            '历史' => 'lsf',
            '政治' => 'zzf',
            '地理' => 'dlf'
        );
        $subjectObject = array();

        $sql = 'SELECT "subject_id","subject_name" FROM "{{subject}}" WHERE "is_del" = 0';
        $result = Yii::app()->db->createcommand($sql);
        $data = $result->queryAll();
        if (!empty($data)) {
            foreach ($data as $value) {
                $key = isset($pointObject[$value['subject_name']]) ? $pointObject[$value['subject_name']] : '';
                if (!empty($key)) {
                    $subjectObject[$value['subject_id']] = $key;
                }
            }
        }
        return $subjectObject;
    }
}